<?php
	/**
	 * Manifest for the application system.
	 * @author IMP
	 */
	
	class ApplicationManifest extends IniParser {
		private $entries = array(), $default = null;
		
		public function __construct(File $mf){
			parent::__construct($mf);
			$sections = $this->getSections();
			
			foreach($sections as $s){
				if(!empty($s['file']) && !empty($s['class']) && !empty($s['parent'])){
					$default = !empty($s['default']) ? $s['default'] : false;
					$e = new ApplicationManifestEntry($s->getName(), new File(PATH_APPS . DS . $s['file']), $s['class'], $s['parent']);
					
					if($default){
						$this->default = &$e;
					}
					
					$this->entries[$s->getName()] = &$e;
				}
			}
		}
		
		public function hasApplication($app){
			return array_key_exists($app, $this->entries);
		}
		
		public function getApplication($app){
			return $this->entries[$app];
		}
		
		public function hasDefault(){
			return $this->default !== null;
		}
		
		public function &getDefault(){
			return $this->default;
		}
	}
?>